package org.dtrd.modules.questionnaire.entity.bean;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.dtrd.modules.device.config.DeviceConstant;

import java.util.concurrent.atomic.AtomicReference;

/**
 * @author 萧
 * @date:2021-11-07 3:38 下午
 **/
@Data
@NoArgsConstructor
@ApiModel(value = "得分结果")
public class ScoreData {

    @ApiModelProperty(value = "类型")
    private String type;

    @ApiModelProperty(value = "分数")
    private Float score;

    @ApiModelProperty(value = "评判结果")
    private String result;

    public ScoreData(String type, Float score) {
        this.type = type;
        this.score = score;
        this.result = formatScoreToText(type, score);
    }


    public String formatScoreToText(String type, Float score) {
        String result = "";
        switch (type) {
            case "生活方式":
                if (score <= 20)
                    result = "生活方式不健康";
                else if (score <= 40)
                    result = "生活方式略健康";
                else if (score <= 48)
                    result = "生活方式较健康";
                break;
            case "身心健康":
                if (score <= 25)
                    result = "身心不健康";
                else if (score <= 50)
                    result = "身心略健康";
                else if (score <= 72)
                    result = "身心较健康";
                break;
            case "自我健康":
                if (score <= 16)
                    result = "自身健康不重视";
                else if (score <= 32)
                    result = "自身健康略重视";
                else if (score <= 40)
                    result = "自身健康较重视";
                break;
        }

        return result;
    }

}
